<?php
class Template_modulesAction extends CommonAction {
	function index(){
		$this->listorder = "sort, id desc";
		$this->listmap = "tm.template_id=".$this->_get('template_id');
        parent::_list("tm","left join __MODULES_CATEGORY__ as m on m.id = tm.pid","tm.*,m.title as mtitle");
		
		$this->assign('template_id',$this->_get('template_id'));
		$this->display();
	}

	public function add(){
		$map = array('id'=> $this->_get('template_id'));
		$pid_list=M('Modules_category')->select();
		
		$template_id = M('Template') -> where($map)->Field('id') -> find();
		$this->assign('pid_list',$pid_list);
		$this->assign('template_id',$template_id['id']);
		parent::add();
	}
	public function edit(){
		$map = array('id'=> $this->_get('template_id'));
		$pid_list=M('Modules_category')->select();
		foreach($pid_list as $k=>$v){
			$pid_list[$k]['sub']=$this->dao->getListToArray1($v['id']);
		}
		$template_id = M('Template') -> where($map)->Field('id') -> find();
		$this->assign('pid_list',$pid_list);
		$template_id = M('Template') -> where($map)->Field('id') -> find();
		$this->assign('template_id',$template_id['id']);
		parent::edit();
	}
	
	
	
}